package com.gist.cithub.user.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gist.common.utils.PageUtils;
import com.gist.common.utils.Query;

import com.gist.cithub.user.dao.InformationDao;
import com.gist.cithub.user.entity.InformationEntity;
import com.gist.cithub.user.service.InformationService;


@Service("informationService")
public class InformationServiceImpl extends ServiceImpl<InformationDao, InformationEntity> implements InformationService {
    @Autowired
    InformationDao informationDao;
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<InformationEntity> page = this.page(
                new Query<InformationEntity>().getPage(params),
                new QueryWrapper<InformationEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public InformationEntity loginByNameAndPassword(String name, String password) {
        QueryWrapper<InformationEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("type");
        Map<String, Object> conditions = new HashMap<>();
        conditions.put("name", name);
        conditions.put("password", password);
        List<InformationEntity> userList= informationDao.selectByMap(conditions);
        if (userList.size()>0){
            return  userList.get(0);

        }

        return null;
    }


}